
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <BIcon>
#include <BReadWrite>
#include <BTexture>
#include <BImage>
#include <BLabel>
#include <BFileDialog>
#include <BStyle>
#include <BGridLayout>
#include <BHBoxLayout>
#include <BVBoxLayout>
#include <BButton>
#include <BComboBox>
#include <BSpinBox>
#include <BListWidget>
#include <BScrollWidget>
#include <BTableWidget>
#include <BMenu>
#include <BSlider>
#include <BCheckBox>
#include <BMainWindow>
#include <BButtonGroup>

#include "ReplaceDialog.h"
#include "CreateLayerDialog.h"
#include "LayerPanel.h"
#include "LayersBoard.h"
#include "PixmapArea.h"

class MainWindow : public BMainWindow
{
public:
	MainWindow();
	~MainWindow();

	bool openImage(const BString& fileName);

protected:
	void slotOpenButtonClicked(BObject* object, const BValue& value);
	void slotSaveButtonClicked(BObject* object, const BValue& value);
	void slotResetButtonClicked(BObject* object, const BValue& value);
	void slotInsertButtonClicked(BObject* object, const BValue& value);
	void slotCanvasResized(BObject* object, const BValue& value);
	void slotChooseCanvasImage(BObject* object, const BValue& value);
	void slotModifyMenuTrigger(BObject* object, const BValue& value);
	void slotZoomValueChanged(BObject* object, const BValue& value);
	void slotResetZoomButtonClicked();
	void slotEventEnabledChecked();
	void slotButtonGroupChecked(BObject* object, const BValue& value);
	void slotOperationEscape(BObject* object, const BValue& value);
	void slotOperation(BObject* object, const BValue& value);
	void slotSelection(BObject* object, const BValue& value);

	void slotArrowUpClicked();
	void slotArrowDownClicked();
	void slotLayerInsertClicked();
	void slotLayerRemoveClicked();
	void slotLayerExportClicked();
	void slotImageSizeChanged(BObject* object, const BValue& value);
	void slotLayerItemSelected(BObject* object, const BValue& value);

	void slotEyeButtonChecked(BObject* object, const BValue& value);
	void slotWidgetFrame(BObject* object, const BValue& value);
	void slotReplaceDialogClosed(BObject* object, const BValue& value);

	void slotPixmapZoomChanged(BObject* object, const BValue& value);
	void slotWidgetSelected(BObject* object, const BValue& value);
	void slotWidgetUnselected(BObject* object, const BValue& value);
	void slotWidgetOrderAdjusted(BObject* object, const BValue& value);
	void slotInsertImageLayer(BObject* object, const BValue& value);
	void slotRemoveImageLayer(BObject* object, const BValue& value);
	void slotLayerPoint(BObject* object, const BValue& value);
	void slotGlobalPoint(BObject* object, const BValue& value);

protected:
	virtual void styleEvent(const BEvent& event);
	virtual void updateEvent(const BEvent& event);

private:
	BButton*				_openButton;
	BButton*				_saveButton;
	BButton*				_resetButton;
	BButton*				_insertButton;
	BButton*				_canvasButton;
	BButton*				_modifyButton;
	BSpinBox*				_canvasWidthSpinBox;
	BSpinBox*				_canvasHeightSpinBox;
	BButton*				_canvasImageButton;
	BSlider*				_zoomSlider;
	BButton*				_resetZoomButton;
	BCheckBox*				_eventEnabledCheckBox;
	BSpinBox*				_layerXSpinBox;
	BSpinBox*				_layerYSpinBox;
	BSpinBox*				_globalXSpinBox;
	BSpinBox*				_globalYSpinBox;

	BMenu*					_canvasMenu;
	BMenu*					_modifyMenu;

	BHolder<BButtonGroup>	_buttonGroup;
	PixmapArea*				_pixmapArea;
	BSpacer*				_pixmapSpacer;
	BVBoxLayout*			_rightLayout;
	LayerPanel*				_imageLayerPanel;
	BHolder<ReplaceDialog>	_replaceDialog;
	BHolder<CreateLayerDialog>	_createLayerDialog;

	BButton*				_arrowUpButton;
	BButton*				_arrowDownButton;
	BButton*				_layerInsertButton;
	BButton*				_layerExportButton;
	BButton*				_layerRemoveButton;
	BComboBox*				_imageSizeComboBox;
	LayersBoard*			_layersBoard;
};

#endif